

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:textfluttertimer/test_provider/model_count.dart';

class TextWatchWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _TextWatchState();
  }

}

class _TextWatchState extends State<TextWatchWidget>{


  @override
  Widget build(BuildContext context) {
    print("_TextWatchState build");
    return Scaffold(
      appBar: AppBar(
        title: Text("Text Watch"),
      ),
      body: Center(
        child: Column(
          children: [
            //Text("count == ${countModel.count}"),
            MyWatchWidget(),
            RaisedButton(onPressed: (){
              context.read<CountModel>().setCount();
            },
              child: Text("点击"),)
          ],
        ),
      ),
    );

  }

}

class MyWatchWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    print("MyWatchWidget build");
    CountModel countModel = context.watch<CountModel>();
    return Text("count == ${countModel.count}");
  }

}
